use car_sa1.dta



encode country, generate(country1)
xtset country1 year

gen aidgdp1 = aid/gdp*100
gen dmpi3 = l_mdmh1*l_persindex
gen lnaid = ln(aid+1)

***NOT INCLUDED
*log-normal OLS
xtreg lnaid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 i.year, fe r

	
xtreg lnaid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 ///
	reg1999 emu i.year, fe r

xtreg lnaid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///w
	l_debt l_koftr l_koffi  fmelecindex ///
	l_mdmh1 l_persindex dmpi3 i.year, fe r
	
xtreg lnaid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	nc2 d_newcars l_vapc1  ///
	l_mdmh1 l_persindex dmpi3 i.year, fe r 
	
*with aidgdp
ppmlhdfe aidgdp1  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year, r
	
ppmlhdfe aidgdp1  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 ///
	reg1999 emu  i.country1 i.year, r

ppmlhdfe aidgdp1  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_debt l_koftr l_koffi  fmelecindex ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year, r
	
ppmlhdfe aidgdp1  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	nc2 d_newcars l_vapc1  ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year, r


***ZINB MODELS

***TABLE 3***
**with vars as inflation, with CFE and YFE

*baseline
zinb aid ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_persindex l_mdmh1 dmpi3 i.country1 i.year, ///
	inflate(l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_persindex l_mdmh1 dmpi3) r difficult 
estimates store zinb_base1a

*with EU vars
zinb aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	reg1999 emu  ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year, ///
	inflate(l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	reg1999 emu  ///
	l_mdmh1 l_persindex dmpi3) r difficult
estimates store zinb_eu1a

*with country vars
zinb aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_debt l_koftr l_koffi  fmelecindex ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year, ///
	inflate(l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_debt l_koftr l_koffi  fmelecindex ///
	l_mdmh1 l_persindex dmpi3) r difficult
estimates store zinb_ctr1a

*with industry vars
zinb aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	nc2 d_newcars l_vapc1  ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year, ///
	inflate(l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	nc2 d_newcars l_vapc1  ///
	l_mdmh1 l_persindex dmpi3) r difficult
estimate store zinb_ind1a

estimates table zinb_base1a zinb_eu1a zinb_ctr1a zinb_ind1a, star 



***TABLE B2.1***
**with CFE + YFE and eu15 only

*baseline
zinb aid ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_persindex l_mdmh1 dmpi3 i.country1 i.year if eu15>0, ///
	inflate(l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_persindex l_mdmh1 dmpi3 ) r difficult 
estimates store zinb_base2

*with EU vars
zinb aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	reg1999 emu  ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year if eu15>0, ///
	inflate(l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	reg1999 emu  ///
	l_mdmh1 l_persindex dmpi3) r difficult
estimates store zinb_eu2

*with country vars
zinb aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_debt l_koftr l_koffi  fmelecindex ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year if eu15>0, ///
	inflate(l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_debt l_koftr l_koffi  fmelecindex ///
	l_mdmh1 l_persindex dmpi3) r difficult
estimates store zinb_ctr2

*with industry vars
zinb aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	nc2 d_newcars l_vapc1  ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year if eu15>0, ///
	inflate(l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	nc2 d_newcars l_vapc1  ///
	l_mdmh1 l_persindex dmpi3) r difficult
estimate store zinb_ind2

estimates table zinb_base2 zinb_eu2 zinb_ctr2 zinb_ind2, star 


***TABLE B3.1***
**with reg1999 > 0 w/ CFE and YFE

*baseline
zinb aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_persindex l_mdmh1 dmpi3  i.country1 i.year  ///
	if reg1999 > 0, ///
	inflate(l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_persindex l_mdmh1 dmpi3) r difficult 
estimates store zinb_base2a

*with EU vars
zinb aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	 emu  ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year ///
	if reg1999 > 0, ///
	inflate(l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 ///
	 emu) r difficult
estimates store zinb_eu2a

*with country vars
zinb aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_debt l_koftr l_koffi  fmelecindex ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year ///
	if reg1999 > 0, ///
	inflate(l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 ///
	l_debt l_koftr l_koffi  fmelecindex) r difficult
estimates store zinb_ctr2a

*with industry vars
zinb aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	nc2 d_newcars l_vapc1  ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year ///
	if reg1999 > 0, ///
	inflate(l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 ///
	nc2 d_newcars l_vapc1) r difficult
estimate store zinb_ind2a


estimates table zinb_base2a zinb_eu2a zinb_ctr2a zinb_ind2a, star 




***TABLE B1***
***PPML w/ CFE and YFE
*baseline
ppmlhdfe aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year, ///
	cluster(country1)
estimate store ppml_base

*EU variables
ppmlhdfe aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	emu ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year ///
	reg1999, cluster(country1)
estimate store ppml_eu

*Country variables
ppmlhdfe aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year ///
	l_koftr l_koffi l_debt  fmelecindex, cluster(country1)
estimate store ppml_ctr

*Industry variables
ppmlhdfe aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year ///
	d_newcars l_vapc1 nc2, cluster(country1)
estimate store ppml_ind

estimate table ppml_base ppml_eu ppml_ctr ppml_ind, star

***TABLE B2.2***
**PPML with CFE + YFE and eu15

*baseline
ppmlhdfe aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year if eu15>0, r
estimate store ppml_base2

*EU variables
ppmlhdfe aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 ///
	reg1999 emu  i.country1 i.year if eu15>0, r
estimate store ppml_eu2

*Country variables
ppmlhdfe aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 ///
	l_koftr l_koffi l_debt  fmelecindex i.country1 i.year if eu15>0, r
estimate store ppml_ctr2

*Industry variables
ppmlhdfe aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 ///
	d_newcars l_vapc1 nc2 i.country1 i.year if eu15>0, r
estimate store ppml_ind2

estimate table ppml_base2 ppml_eu2 ppml_ctr2 ppml_ind2, star



***TABLE B3.2***
**PPML with CFE + YFE and subsample with reg1999 > 0 

*baseline
ppmlhdfe aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 i.country1 i.year ///
	if reg1999 > 0, r 
estimate store ppml_base4

*EU variables
ppmlhdfe aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 ///
	reg1999 emu  i.country1 i.year ///
	if reg1999 > 0, r
estimate store ppml_eu4

*Country variables
ppmlhdfe aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 ///
	l_koftr l_koffi l_debt  fmelecindex ///
	i.country1 i.year ///
	if reg1999 > 0, r
estimate store ppml_ctr4

*Industry variables
ppmlhdfe aid  ///
	l_incentives l_enop1 l_vprange  ///
	econenop econpolicyvp  ///
	l_mdmh1 l_persindex dmpi3 ///
	d_newcars l_vapc1 nc2 i.country1 i.year ///
	if reg1999 > 0, r
estimate store ppml_ind4

estimate table ppml_base4 ppml_eu4 ppml_ctr4 ppml_ind4, star




**correlation matrix
mkcorr aid /// 
l_incentives1 l_enop1 l_vprange ///
l_mdmh1 l_persindex ///
reg1999 emu  l_koftr l_koffi l_debt fmelecindex ///
d_newcars2 l_vapc1 nc2, ///
log(correlation.xls) replace num aster label sig cdec(3) casewise

pwcorr aid /// 
l_incentives1 l_enop1 l_vprange ///
l_mdmh1 l_persindex ///
reg1999 emu  l_koftr l_koffi l_debt fmelecindex ///
d_newcars2 l_vapc1 nc2, star(0.05) casewise

 
***REGRESSION TABLES

***ZINB - TABLE 3
outreg2 [zinb_base1a zinb_eu1a zinb_ctr1a zinb_ind1a] using Table_3ZINB.xls, ///
title("Zero-inflated Negative Binomial regression for state aid to the European automotive sector (1992-2011)") ///
stats(coef se blank) ///
bdec(3) sdec(3) pdec(3) ///
seeout label ///
keep(l_incentives l_enop1 l_vprange  econenop econpolicyvp  l_mdmh1 l_persindex dmpi3 reg1999  l_koftr l_koffi l_debt  fmelecindex emu  d_newcars2 l_vapc1 nc2) ///
sortvar(l_incentives l_enop1 l_vprange econenop econpolicyvp l_mdmh1 l_persindex dmpi3 reg1999 emu  l_koftr l_koffi l_debt  fmelecindex  d_newcars2 l_vapc1 nc2) 


***ZINB with CFE and reg1999 > 0 - TABLE 3.1
outreg2 [zinb_base2a zinb_eu2a zinb_ctr2a zinb_ind2a] using Table_ZINB_B3_1.xls, ///
title("Zero-inflated Negative Binomial regression for state aid to the European automotive sector (1992-2011)") ///
stats(coef se blank) ///
bdec(3) sdec(3) pdec(3) ///
seeout label ///
keep(l_incentives l_enop1 l_vprange  econenop econpolicyvp  l_mdmh1 l_persindex dmpi3 reg1999  l_koftr l_koffi l_debt  fmelecindex emu  d_newcars2 l_vapc1 nc2) ///
sortvar(l_incentives l_enop1 l_vprange econenop econpolicyvp l_mdmh1 l_persindex dmpi3 reg1999 emu  l_koftr l_koffi l_debt  fmelecindex  d_newcars2 l_vapc1 nc2) 

***ZINB with CFE and eu15 only - TABLE B2.1
outreg2 [zinb_base2 zinb_eu2 zinb_ctr2 zinb_ind2] using Table_ZINB_B2_1.xls, ///
title("Zero-inflated Negative Binomial regression for state aid to the European automotive sector in the EU15 (1992-2011)") ///
stats(coef se blank) ///
bdec(3) sdec(3) pdec(3) ///
seeout label ///
keep(l_incentives l_enop1 l_vprange  econenop econpolicyvp  l_mdmh1 l_persindex dmpi3 reg1999z  l_koftr l_koffi l_debt  fmelecindex emu econcrisis d_newcars2 l_vapc1 nc2) ///
sortvar(l_incentives l_enop1 l_vprange econenop econpolicyvp l_mdmh1 l_persindex dmpi3 reg1999z emu econcrisis l_koftr l_koffi l_debt  fmelecindex  d_newcars2 l_vapc1 nc2) 


***PPML - TABLE B1
outreg2 [ppml_base1 ppml_eu1 ppml_ctr1 ppml_ind1] using Table_B1PPML.xls, ///
title("PPML regression for state aid to the European automotive sector (1992-2011)") ///
stats(coef se blank) ///
bdec(3) sdec(3) pdec(3) ///
seeout label ///
keep(l_incentives l_enop1 l_vprange  econenop econpolicyvp  l_mdmh1 l_persindex dmpi3 reg1999  l_koftr l_koffi l_debt  fmelecindex emu  d_newcars2 l_vapc1 nc2) ///
sortvar(l_incentives l_enop1 l_vprange econenop econpolicyvp l_mdmh1 l_persindex dmpi3 reg1999 emu  l_koftr l_koffi l_debt  fmelecindex  d_newcars2 l_vapc1 nc2) 


***PPML with CFE and reg1999 > 0 - TABLE 3.2
outreg2 [ppml_base4 ppml_eu4 ppml_ctr4 ppml_ind4] using Table_PPML_B3.2.xls, ///
title("PPML regression for state aid to the European automotive sector (1992-2011)") ///
stats(coef se blank) ///
bdec(3) sdec(3) pdec(3) ///
seeout label ///
keep(l_incentives l_enop1 l_vprange  econenop econpolicyvp  l_mdmh1 l_persindex dmpi3 reg1999  l_koftr l_koffi l_debt  fmelecindex emu  d_newcars2 l_vapc1 nc2) ///
sortvar(l_incentives l_enop1 l_vprange econenop econpolicyvp l_mdmh1 l_persindex dmpi3 reg1999 emu  l_koftr l_koffi l_debt  fmelecindex  d_newcars2 l_vapc1 nc2) 

***PPML with CFE and YFE and eu15 only - TABLE B2.2
outreg2 [ppml_base2 ppml_eu2 ppml_ctr2 ppml_ind2] using Table_PPML_B2_2.xls, ///
title("PPML regression for state aid to the European automotive sector (1992-2011)") ///
stats(coef se blank) ///
bdec(3) sdec(3) pdec(3) ///
seeout label ///
keep(l_incentives l_enop1 l_vprange  econenop econpolicyvp  l_mdmh1 l_persindex dmpi3 reg1999z  l_koftr l_koffi l_debt  fmelecindex emu econcrisis d_newcars2 l_vapc1 nc2) ///
sortvar(l_incentives l_enop1 l_vprange econenop econpolicyvp l_mdmh1 l_persindex dmpi3 reg1999z emu econcrisis l_koftr l_koffi l_debt  fmelecindex  d_newcars2 l_vapc1 nc2) 

